package com.hp.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hp.mapper.JimiMapper;
import com.hp.pojo.Jimi;
import com.hp.service.JimiService;
import com.hp.util.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class JimiServiceImpl implements JimiService {

    @Resource
    private JimiMapper jimiMapper;

    @Override
    public PageResult fingPage(int pageNum, int pageSize, Jimi jimi) {
        PageHelper.startPage(pageNum,pageSize);
        Page page=(Page)jimiMapper.findAll(jimi);
        PageResult pageResult = new PageResult(page.getTotal(),page.getResult());
        return pageResult;
    }

   /* @Override
    public PageResult fingPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        Page page=(Page)jimiMapper.findList();
        PageResult pageResult = new PageResult(page.getTotal(),page.getResult());
        return pageResult;
    }*/

    @Override
    public List<Jimi> findList() {
        return jimiMapper.findList();
    }

    @Override
    public void add(Jimi jimi) {
        jimiMapper.add(jimi);
    }

    @Override
    public Jimi findById(int id) {
        return jimiMapper.findById(id);
    }

    @Override
    public void update(Jimi jimi) {
        jimiMapper.update(jimi);
    }

    @Override
    public void delete(int id) {
        jimiMapper.delete(id);
    }
}
